﻿@model WishlistModel
@using Nop.Web.Models.ShoppingCart;

@{
    Layout = "~/Views/Shared/_ColumnsOne.cshtml";

    //title
    Html.AddTitleParts(T("PageTitle.Wishlist").Text);
}
<div class="container">
    <div class="row">
        <div class="col-md-12">
            
            <div class="panel panel-default form-panel">
                <div class="panel-heading">
                    <h3>
                        @if (Model.IsEditable)
                        {
                            @T("Wishlist")
                        }
                        else
                        {
                            @String.Format(T("Wishlist.WishlistOf").Text, Model.CustomerFullname)
                        }
                    </h3>
                </div>
                <div class="panel-body">
                    <div class="wishlist-content">
                        @if (Model.Items.Count > 0)
                        {
                            if (Model.Warnings.Count > 0)
                            {
                                <div class="alert alert-danger square-box">
                                    <div>
                                        @for (int i = 0; i < Model.Warnings.Count; i++)
                                        {
                                            <div>@Model.Warnings[i]</div>
                                        }
                                    </div>
                                </div>
                            }
                            using (Html.BeginRouteForm("Wishlist", FormMethod.Post))
                            {
                                <table class="cart table table-bordered">
                                    <colgroup>
                                        @if (Model.IsEditable)
                                        {
                                            <col width="1" />
                                        }
                                        @if (Model.DisplayAddToCart)
                                        {
                                            <col width="1" />
                                        }
                                        @if (Model.ShowSku)
                                        {
                                            <col width="1" />
                                        }
                                        @if (Model.ShowProductImages)
                                        {
                                            <col width="1" />
                                        }
                                        <col />
                                        <col width="1" />
                                        <col width="1" />
                                        <col width="1" />
                                    </colgroup>
                                    <thead>
                                        <tr class="cart-header-row">
                                            @if (Model.IsEditable)
                                            {
                                                <th>
                                                    @T("ShoppingCart.Remove")
                                                </th>
                                            }
                                            @if (Model.DisplayAddToCart)
                                            {
                                                <th class="cart">
                                                    @T("ShoppingCart.AddToCart")
                                                </th>
                                            }
                                            @if (Model.ShowSku)
                                            {
                                                <th>
                                                    @T("ShoppingCart.SKU")
                                                </th>
                                            }
                                            @if (Model.ShowProductImages)
                                            {
                                                <th class="picture">
                                                </th>
                                            }
                                            <th>
                                                @T("ShoppingCart.Product(s)")
                                            </th>
                                            <th>
                                                @T("ShoppingCart.UnitPrice")
                                            </th>
                                            <th>
                                                @T("ShoppingCart.Quantity")
                                            </th>
                                            <th class="end">
                                                @T("ShoppingCart.ItemTotal")
                                            </th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        @foreach (var item in Model.Items)
                                        {
                                            <tr class="cart-item-row">
                                                @if (Model.IsEditable)
                                                {
                                                    <td class="remove-from-cart">
                                                        <input type="checkbox" name="removefromcart" value="@(item.Id)" />
                                                    </td>
                                                }
                                                @if (Model.DisplayAddToCart)
                                                {
                                                    <td class="add-to-cart">
                                                        <input type="checkbox" name="addtocart" value="@(item.Id)" />
                                                    </td>
                                                }
                                                @if (Model.ShowSku)
                                                {
                                                    <td class="sku nobr">
                                                        @item.Sku
                                                    </td>
                                                }
                                                @if (Model.ShowProductImages)
                                                {
                                                    <td class="product-picture">
                                                        <img alt="@item.Picture.AlternateText" src="@item.Picture.ImageUrl" title="@item.Picture.Title" />
                                                    </td>
                                                }
                                                <td class="product">
                                                    <a href="@Url.RouteUrl("Product", new { SeName = item.ProductSeName })">@item.ProductName</a>
                                                    @if (!String.IsNullOrEmpty(item.AttributeInfo))
                                                    {
                                                        <div class="attributes">
                                                            @Html.Raw(item.AttributeInfo)
                                                        </div>
                                                    }
                                                    @if (!String.IsNullOrEmpty(item.RecurringInfo))
                                                    {
                                                        <div class="recurring-info">
                                                            @Html.Raw(item.RecurringInfo)
                                                        </div>
                                                    }
                                                    @if (item.Warnings.Count > 0)
                                                    {
                                                        <div class="message-error">
                                                            <ul>
                                                                @for (int i = 0; i < item.Warnings.Count; i++)
                                                                {
                                                                    <li>@item.Warnings[i]</li>
                                                                }
                                                            </ul>
                                                        </div>
                                                    }
                                                </td>
                                                <td class="unit-price nobr">
                                                    <span class="product-unit-price">@item.UnitPrice</span>
                                                </td>
                                                <td class="qty nobr">
                                                    @if (Model.IsEditable)
                                                    {
                                                        if (item.AllowedQuantities.Count > 0)
                                                        {
                                                            <select name="itemquantity@(item.Id)" class="qty-dropdown">
                                                                @foreach (var qty in item.AllowedQuantities)
                                                                {
                                                                    <option selected="@qty.Selected" value="@qty.Value">@qty.Value</option>
                                                                }
                                                            </select>
                                                        }
                                                        else
                                                        {
                                                            <input name="itemquantity@(item.Id)" type="text" value="@(item.Quantity)" class="qty-input"/>
                                                        }
                                                    }
                                                    else
                                                    {
                                                        <span>@item.Quantity</span>
                                                    }
                                                </td>
                                                <td class="subtotal nobr end">
                                                    <span class="product-subtotal">@item.SubTotal</span>
                                                    @if (!String.IsNullOrEmpty(item.Discount))
                                                    {
                                                        <div class="discount">
                                                            @T("ShoppingCart.ItemYouSave"): @item.Discount
                                                        </div>
                                                    }
                                                </td>
                                            </tr>
                                        }
                                    </tbody>
                                </table>                
                                <div class="buttons">
                                    <div class="common-buttons">
                                        @if (Model.IsEditable)
                                        {
                                            <input type="submit" name="updatecart" value="@T("Wishlist.UpdateCart")" class="btn btn-default" />
                                        }
                                        @if (Model.DisplayAddToCart)
                                        {
                                            <input type="submit" name="addtocartbutton" value="@T("ShoppingCart.AddToCart")" class="btn btn-default" />
                                        }
                                        @if (Model.IsEditable && Model.EmailWishlistEnabled)
                                        {
                                            <input type="button" value="@T("Wishlist.EmailAFriend")" class="btn btn-default" onclick="setLocation('@Url.RouteUrl("EmailWishlist")')" />
                                        }
                                    </div>
                                </div>        
                            }
                        }
                        else
                        {
                            @T("Wishlist.CartIsEmpty")
                        }
                    </div>
                    @if (Model.IsEditable && Model.Items.Count > 0)
                    {
                        <div class="share-info">
                            <p>
                                <span class="share-label">@T("Wishlist.YourWishlistURL"):</span>
                            </p>
                            <p>
                                <a href="@Url.RouteUrl("Wishlist", new { customerGuid = Model.CustomerGuid })" class="share-link">@Url.RouteUrl("Wishlist", new { customerGuid = Model.CustomerGuid }, "http")</a>
                            </p>
                        </div>
                    }
                </div>
            </div>

        </div>
    </div>
    
</div>
